package com.my.study.hutool.core.convert;

import cn.hutool.core.convert.AbstractConverter;
import com.my.study.utils.Money;
import com.my.study.utils.User;

/**
 * @author: yidujun
 * @create: 2021/06/30 16:00
 */
public class MoneyConverter extends AbstractConverter<Money> {
    private static final long serialVersionUID = 3943585331031432640L;

    private final Class<? extends Money> targetType;

    public MoneyConverter() {
        targetType = Money.class;
    }

    @Override
    protected Money convertInternal(Object value) {
        Money money = new Money();
        User user = (User) value;
        money.setRate(user.getUserName());
        money.setCount(user.getAge());

        return money;
    }

    @Override
    public Class<Money> getTargetType() {
        return ((Class<Money>) targetType);
    }
}
